//
//  DWDTextView.swift
//  dwdWb
//
//  Created by Dengdwd on 15/10/18.
//  Copyright © 2015年 dwd. All rights reserved.
//

import UIKit
private let LABEL_W:CGFloat = 5
class DWDTextView: UITextView {


    var placeHolder:String?{
        didSet{
        placeLabel.text = placeHolder
        }
    }
    
    override var font:UIFont? {
        didSet {
        placeLabel.font = font
        }
    }
    override init(frame: CGRect, textContainer: NSTextContainer?) {
        super.init(frame: frame, textContainer: textContainer)
        
        addSubview(placeLabel)

    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
    lazy var placeLabel:UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFontOfSize(16)
        label.textColor = UIColor.grayColor()
        label.text = "dfsihdfsfbhdojifjfojpj"
        label.numberOfLines = 0
        return label
        }()
    

    override func layoutSubviews() {
        super.layoutSubviews()
        placeLabel.x = LABEL_W
        placeLabel.y = 8
        placeLabel.size = (placeHolder ?? "").size(placeLabel.font, constrainedToSize: CGSize(width: SCREENW - 2 * LABEL_W, height: CGFloat(MAXFLOAT)))
        
    }
    deinit {
    NSNotificationCenter.defaultCenter().removeObserver(self)
    }
}
